package frontend.utils;

import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
import org.apache.wicket.util.tester.WicketTester;
import org.junit.Before;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import frontend.core.PrometeicaWebApplication;

public class WicketTestBase{

	private PrometeicaWebApplication application;
	private WicketTester tester;
	
	@Before
	public void setUp() {
		final ApplicationContext context = new ClassPathXmlApplicationContext("test-applicationContext.xml");

		application = new PrometeicaWebApplication() {
			@Override
			protected void addSpringInitializer() {
				getComponentInstantiationListeners().add(new SpringComponentInjector(application, context));
			}
		};
		application.setApplicationContext(context);
		tester = new WicketTester(application);
	}
	
	protected WicketTester getTester() {
		return tester;
	}
}
